<form>
    <div class="form-group" style="margin-bottom: 20px;" >
            <span class="glyphicon glyphicon-user" style="font-size: 50px;margin-left: 20px;"></span>
            <span id="err_img" class="glyphicon"  style="color: red;vertical-align: bottom;  font-size: 25px;margin-left: 20px;"></span>
            <span id="error_client"style="position: absolute;left: 145px;top: 33px;"></span>
    </div>
    <div class="form-group col-sm-8 col-lg-8">
        <label for="clientnameadd">客户名称</label>
        <input type="text" class="form-control input-lg" id="clientnameadd" placeholder="请输入客户名称">
    </div>
    <div class="form-group  col-sm-8 col-lg-8">
        <label for="clientgoodsadd" >客户购买商品</label>
        <input type="text" class="form-control input-lg" id="clientgoodsadd" placeholder="请输入客户购买商品">
    </div>
    <div class="form-group  col-sm-8 col-lg-8">
        <label for="clientnumadd" >数量</label>
        <input type="text" class="form-control input-lg" id="clientnumadd" placeholder="请输入客户购买的数量">
    </div>
  <div class="form-group col-sm-8 col-lg-8">
       <button type="button" class="btn btn-primary btn-lg" id="cientsubmit">Submit</button>
        <button type="button" class="btn btn-primary btn-lg" id="clientback">Back</button>
  </div>
</form>
<script type="application/javascript">
        $(function () {
            $("#cientsubmit").on("click",btnLogin);
            $("#clientback").on("click",function () {
                $("#sec_right").load("/client",function () {
                    doGetObjects();
                })
            })
            errorfocus();
            function errorfocus() {
                $("#clientnameadd").focus(function () {
                    clearInterval();
                    $("#error_client").html("");
                    $("#err_img").removeClass("glyphicon-volume-up");
                })
                $("#clientgoodsadd").focus(function () {
                    clearInterval();
                    $("#error_client").html("");
                    $("#err_img").removeClass("glyphicon-volume-up");
                })
                $("#clientnumadd").focus(function () {
                    clearInterval();
                    $("#error_client").html("");
                    $("#err_img").removeClass("glyphicon-volume-up");
                })
            }
            function error_mes() {
                clearInterval();
                $("#err_img").addClass("glyphicon-volume-up");
                var count=0;
               var err_timer=setInterval(function () {
                    count++;
                    if (count%2==0){
                        $("#err_img").removeClass("glyphicon-volume-up");
                        // clearInterval(err_img_client);
                    }else{
                        $("#err_img").addClass("glyphicon-volume-up");
                    }
                    if ($("#error_client").html()===''){
                        clearInterval(err_timer);
                    }
                },500)

                return ;
            }
            function btnLogin() {
                const clientnameadd=$("#clientnameadd").val();
                const clientgoodsadd=$("#clientgoodsadd").val();
                const clientnumadd=$("#clientnumadd").val();
                if (clientnameadd==''){
                    $("#error_client").html("提示：客户姓名不能为空");
                    error_mes();
                }else if (clientgoodsadd==''){
                    $("#error_client").html("提示：客户购买商品不能为空");
                    error_mes();
                }else if (clientnumadd==''){
                    $("#error_client").html("提示：购买商品数量不能为空");
                    error_mes();
                }else{
                    clientAddPost();
                }
            }
function clientAddPost() {
    const clientnameadd=$("#clientnameadd").val();
    const clientgoodsadd=$("#clientgoodsadd").val();
    const clientnumadd=$("#clientnumadd").val();
    const url="/client/doSaveClient";
    const  data={
        "clientname":clientnameadd,
        "clientpayname":clientgoodsadd,
        "clientnum":clientnumadd
    }
    $.post(url,data,function (result) {
            console.log(result);
            if (result.status===0){
                $("#gridSystemModalLabel").html("客户信息添加失败提示")
                $("#error_content").html("抱歉:"+result.message);
                $("#error_modal").modal("show");
            }else{
                $("#sec_right").load("/client",function () {
                    doGetObjects();
                })
            }
    })
}

        })
</script>